<template>
	<view class="payment">
		<image class="sign_success" :src="url+'/static/index/sign-success.png'" mode="widthFix"></image>
		<view class="pay_tip">支付成功</view>
			<view class="price">
				<text>￥</text>{{data.payMoney}}
			</view>
			<view class="line"></view>
			<view class="pay_body">
				<view class="pay_item">
					<text class="pay_item_left">订单编号</text>
					<view class="pay_time_right" @click="copy(data.orderNo)" style="display: flex;flex-direction: row; align-items: center; ">
						<view class="ellipseHide" style="max-width:380rpx;">{{data.orderNo}}</view>
						<view class="copy">复制</view>
					</view>
				</view>
				<view class="pay_item">
					<text class="pay_item_left">交易单号</text>
					<view class="pay_time_right">
						<text>{{data.thirdPartyNo}}</text>
					</view>
				</view>
				<view class="pay_item">
					<text class="pay_item_left">交易时间</text>
					<view class="pay_time_right">
						<text>{{data.transactionTime}}</text>
					</view>
				</view>
			</view>
			<view class="repayments" @click="repaymentSu">返回首页</view>
	</view>
</template>

<script>
    var goldPlan = require('../../../../common/jgoldplan-1.0.0.js');
    import api from '@/api/api.js'
	export default {
		data() {
			return {
				data:{},
			}
		},
		 props:{
		  orderId: String,
		  outStatus: {
			  type: Number,
			  default: 1
		  },
        },
		created(e) {
			this.url = this.domainName
			console.log(this.orderId)
			console.log(this.outStatus)
			this.getPayResult()
		},
		methods: {
			async getPayResult(){
				uni.showLoading({ title:'加载中' })
				try{
					var res = await api.getPayResult(this.orderId)
					if(res.result != "" ){
						  this.data = res.result
						  uni.hideLoading()
					}else{
						 if(this.num1 < 30 ){
							  setTimeout(res=>{
								   this.getPayResult()
								   this.num1++
							  },1000)
						 }else{
							uni.showToast({
								title:'请求超时！',
								icon:'none'
							})
						 }
					}
				}catch{
					uni.hideLoading()
				}

			},
			copy(text){
				if(text != ''){
					var _this = this
					 _this.$copyText(text).then(
                        res => {
                          uni.showToast({
                            title: '复制成功',
                            icon: 'none'
                          })
                        }
                      )
				}
			},
			repaymentSu(){
				//微信支付 1 第三方支付 2
				if(this.outStatus == 2){
					var mchData = {
						action: 'jumpOut',
						jumpOutUrl: this.url //跳转的页面
					}				
					var pData = JSON.stringify(mchData);
					parent.postMessage(pData, 'https://payapp.weixin.qq.com')
				}else{
					uni.reLaunch({
						url:'/pages/index/index'
					})
				}
				
			}
		}
	}
</script>

<style scoped>
	.payment{
		width: 100%;
		padding-top: 80rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.payment .sign_success{
		width: 188rpx;
		height: 188rpx;
	}
	.pay_tip{
		text-align: center;
		font-weight: 400;
		font-size: 30rpx;
		color: #000000;
		margin-top: 20rpx;
	}
	.price{
		color: #FF361B;
		font-size: 48rpx;
		margin-top: 6rpx;
	}
	.price text{
		font-size: 34rpx;
	}
	.line{
		width: 668rpx;
		margin-top: 32rpx;
		margin-bottom: 78rpx;
		border-bottom: 1rpx solid #D8D8D8;
	}
	.pay_item{
		width: 100%;
		min-width: 620rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 36rpx;
		font-size: 28rpx;
		font-weight: 400;
	}
	.pay_item .pay_item_left{
		color: rgba(153, 153, 153, 0.8);
	}
	.pay_item .pay_time_right{
		color: #000000;
		max-width: 460rpx;
	}
	.pay_item .pay_time_right .copy{
		margin-left: 16rpx;
		color: #1774FF;
		text-align: right;
	}
	.repayments{
		width: 276rpx;
		height: 80rpx;
		border: 2rpx solid #CFCED1;
		border-radius: 200rpx;
		text-align: center;
		line-height: 80rpx;
		margin-top: 80rpx;
		color: #2C2A2F;
		font-size: 32rpx;
	}
</style>
